package Action;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.openexpdao;
import Entity.OpenExp;
import mapper.Openexpmapper;

/**
 * Servlet implementation class EDateServlet
 */
@WebServlet("/EDateServlet")
public class EDateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public EDateServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	        String d =request.getParameter("date");
	        java.util.Date da=null;
	        try {
	            da= sdf.parse(d);
	        } catch (ParseException e) {
	            e.printStackTrace();
	        }
	        java.sql.Date date = new java.sql.Date(da.getTime());
	        Openexpmapper om = new openexpdao();
	        List<OpenExp> lo = om.queryOeByDate(date);
	        request.setAttribute("lo",lo);
	        request.getRequestDispatcher("class_total.jsp").forward(request,response);
	}

}
